<!DOCTYPE html>
<html>
<head>
    {include file="layout:_meta" /}
</head>
<body>

<div class="layui-form" lay-filter="layuiadmin-form-admin" id="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">订单编号</label>
            <div class="layui-input-inline">
                <input type="text" placeholder="" lay-reqtext="" readonly="readonly"
                       autocomplete="off" value="{:isset($order.sn)?$order.sn:''}" class="layui-input"
                       style="border: none;">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">下单时间</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" nplaceholder="yyyy-MM-dd HH:mm:ss"
                       value="{:isset($order.create_time)?$order.create_time:''}" readonly="readonly"
                       style="border: none;">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">结束时间</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" placeholder="yyyy-MM-dd HH:mm:ss"
                       value="{:isset($order.update_time)?$order.update_time:''}" readonly="readonly"
                       style="border: none;">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">实付金额</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" placeholder=订单实付金额"
                       value="{:isset($order.price)?$order.price:''}" readonly="readonly"
                       style="border: none;">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">订单状态</label>
            <div class="layui-input-inline">
                {if condition="isset($order.state)&& $order.state eq 0"}
                <div class="layui-input" readonly="readonly" style="border: none;color: red;line-height:38px;">订单取消
                </div>
                {elseif $order.state eq 1 /}
                <div class="layui-input" readonly="readonly" style="border: none;color: #40AFFE;line-height:38px;">
                    待接订单
                </div>
                {elseif $order.state eq 2 /}
                <div class="layui-input" readonly="readonly" style="border: none;color: #40AFFE;line-height:38px;">
                    已接订单
                </div>
                {elseif $order.state eq 3 /}
                <div class="layui-input" readonly="readonly" style="border: none;color: #40AFFE;line-height:38px;">
                    订单完成
                </div>
                {/if}
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">付款状态</label>
            <div class="layui-input-inline">
                {if condition="isset($order.pay_state)&& $order.pay_state eq '0'"}
                <div class="layui-input" readonly="readonly" style="border: none;color: red;line-height:38px;">未付款</div>
                {else /}
                <div class="layui-input" readonly="readonly" style="border: none;color: #40AFFE;line-height:38px;">已付款
                </div>
                {/if}
            </div>
        </div>
    </div>
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>存放物品填写</legend>
    </fieldset>
    <div class="layui-form-item">
        <label class="layui-form-label">酒还剩</label>
        <div class="layui-input-block">
            {if condition="isset($list.state)&&$list.state==1"}
            <input type="text"  placeholder="" lay-reqtext="" readonly="readonly"
                   autocomplete="off" value="{:isset($list.goods_num)?$list.goods_num:''}" class="layui-input" style="border: none;">
            {else /}
            <input type="text" class="layui-input"  placeholder=""
                   value="{:isset($list.goods_num)?$list.goods_num:'0'}" name="goods_num" style="border: none;">
            {/if}
        </div>
        <div class="layui-input-block" style="color: #c0ccda">可填写-例子：1瓶 、 1件 或者1箱等</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">食品还剩</label>
        <div class="layui-input-block">
            {if condition="isset($list.state)&&$list.state==1"}
            <input type="text"  placeholder="" lay-reqtext="" readonly="readonly"
                   autocomplete="off" value="{:isset($list.food)?$list.food:''}" class="layui-input" style="border: none;">
            {else /}
            <input type="text" class="layui-input"  placeholder=""
                   value="{:isset($list.food)?$list.food:'0'}" name="food" style="border: none;">
            {/if}
        </div>
        <div class="layui-input-block" style="color: #c0ccda">可填写-例子：花生一包、西瓜一个等</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">其他/备注</label>
        <div class="layui-input-block">
            {if condition="isset($list.state)&&$list.state==1"}
            <input type="text"  placeholder="" lay-reqtext="" readonly="readonly"
                   autocomplete="off" value="{:isset($list.other)?$list.other:''}" class="layui-input" style="border: none;">
            {else /}
            <textarea name="other" lay-verify=""  placeholder="请输入描述" autocomplete="off" class="layui-textarea">{:isset($list.other)?$list.other:''}</textarea>
            {/if}
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-block">
            {if condition="isset($list.state)&&$list.state==1"}
            <input type="text"  placeholder="" lay-reqtext="" readonly="readonly"
                   autocomplete="off" value="已取出" class="layui-input" style="border: none;">
            {else /}
            <input type="checkbox" lay-filter="state"  value="0" name="state" lay-skin="switch" lay-text="取出|存储中" >
            {/if}
        </div>
        <div class="layui-input-block" style="color: #c0ccda">默认为存储中,选择取出后,所有项都变为不可操作（因为已取出）</div>
    </div>

    <div class="layui-form-item layui-hide">
        <input type="hidden" name="id" value="{:isset($list['id'])?$list['id']:''}">
        <input type="hidden" name="order_id" value="{:isset($list['order_id'])?$list['order_id']:$order_id}">
        <input type="hidden" name="token" value="{:isset($list['token'])?$list['token']:''}">
        <input type="button" lay-submit lay-filter="addEdit" id="addEdit" value="确认">
    </div>
</div>
{include file="layout:_footer" /}
<script>
    layui.config({
        base: '__static__/admin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form', 'upload', 'xmSelect', 'laydate'], function () {
        var form = layui.form, $ = layui.$, upload = layui.upload, xmSelect = layui.xmSelect, laydate = layui.laydate;

        //角色多选框
        var xm_select = xmSelect.render({
            el: '#xm-select',
            tips: '请选择分组',
            prop: {name: 'name', value: 'id'},
            name: 'cate_id',
            layVerify: 'required',
            data: []
        });

        //获取数据以及赋值
        $.get("{:url('ad/edit')}", {id: "{:isset($list['id'])?$list['id']:''}"}, function (res) {
            xm_select.update({data: res.roleList});
            xm_select.setValue(res.role)
        });

        //拖拽上传 单图上传
        var uploadInst = upload.render({
            elem: '#headImg'
            , url: "/admin/index/upload_img" + '?uptype=ad'
            , size: 120
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
            }
            , done: function (res) {
                console.log(res.code, '==========================>图片上传返回<');
                //如果上传失败
                if (res.code != 0) {
                    return layer.msg('上传失败');
                }
                //上传成功
                //打印后台传回的地址: 把地址放入一个隐藏的input中, 和表单一起提交到后台, 此处略..
                /*   console.log(res.data.src);*/
                //   window.parent.uploadHeadImage(res.files);
                var demoText = $('#demoText');
                // $('#ad_img').val(res.files);
                $('#ad_img').val(res.data.img_url);
                console.log(demoText, '===========>,<!!!');
                demoText.html('<span style="color: #8f8f8f;">上传成功!!!</span>');
            }
            , error: function () {
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            }
        });
        //end
        //日期时间选择器
        laydate.render({
            elem: '#starttime'
            , type: 'datetime'
            , trigger: 'click'//呼出事件改成click
        });
        //日期时间选择器
        laydate.render({
            elem: '#endtime'
            , type: 'datetime'
            , trigger: 'click'//呼出事件改成click
        });
        // 监听类型操作
        $("#typevalue").hide();
        form.on('select(type)', function (data) {
            console.log(data)
            console.log(data.elem); //得到select原始DOM对象
            console.log(data.value); //得到被选中的值
            console.log(data.othis); //得到美化后的DOM对象
            var value = data.value;
            if (value == "1") {
                $("#typevalue").hide();
            } else {
                $("#typevalue").show();
            }
        });
        //状态
        form.on('switch(state)', function (data) {
            this.value = this.checked ? 1 : 0;
        });

    })
</script>
</body>
</html>